
	footer.init();
	header.init('设置支付密码');
	var tel = window.sessionStorage.getItem('payPwd');
	tel = JSON.parse(tel).tel;
	var ptel = tel.substr(0, 3) + '****' + tel.substr(7);
	$('#tel').val(ptel);
window.onload =function(){
	
	$('body').on('click','.payPwd',function(){
		$(this).find('input').val();
	});
	
	$('body').on('click','.confirm',function(){
		$(this).find('input').val();
	});
	
	$('body').on('blur','.confirm input',function(){
		var pwd1 = $('.payPwd input').val(),
		pwd2 = $(this).val();
		if(pwd1 != pwd2){
			layer.msg('两次密码输入不一致，请重新输入');
			return;
		}
		 
	});
	
	$('body').on('click','.save',function(){
		 clearInterval(hander);
        $('#sendToTel').text("获取验证码");
        $('#sendToTel').removeAttr("disabled");
		var pay_pwd = $('#pay_pwd').val();
		var q_pwd = $('#q_pwd').val();
		var tel = window.sessionStorage.getItem('payPwd');
		tel = JSON.parse(tel).tel;
		var code = $('#code').val();
		if(!pay_pwd){
			layer.msg('支付密码不能为空');
			return false;
		}else if(q_pwd != pay_pwd){
			layer.msg('两次密码输入不一致');
			return false;
		}else if(!code){
			layer.msg('验证码不能为空');
			return false;
		}
		app.ajax(
			'/Member/Setting/pay_password_update',
			{
				pay_password : pay_pwd,
				q_pay_password : q_pwd,
				mobile : tel,
				code : code
			},function(res){
				if(res.code == 200){
					layer.msg('设置支付密码成功');
				}else{
					layer.msg(res.msg);
				}
			});
	});
	
	var hander = null;
	$('body').on('click','#sendToTel',function(){
		var pwd1 = $('.payPwd input').val(),
		pwd2 = $('.confirm input').val();
		if(pwd1 != pwd2){
			layer.msg('两次密码输入不一致，请重新输入');
			return;
		}
		$('#getcode').val('');
		var btn = $(this);
		var tel = window.sessionStorage.getItem('payPwd');
		tel = JSON.parse(tel).tel;
		var time = 60;
		app.ajax(
			'/Index/Index/send',
			{
				mobile : tel
			},function(res){
				 $("#sendToTel").text("发送成功");
				 var time = 60;
               hander = setInterval(function () {
                    if (time <= 0) {
                        canSend = true;
                        clearInterval(hander);
                        btn.text("获取验证码");
                        btn.removeAttr("disabled");
                    }
                    else {
                        canSend = false;
                        time--;
                        btn.attr({ "disabled": "disabled" });
                        btn.text( time + "s后可重新发送");
                }
			},1000);
		});
	});

};
